# 自动收集所有.cpp和.h文件（递归子目录）
file(GLOB_RECURSE SOURCES  "*.cpp" "*.c")
file(GLOB_RECURSE HEADERS  "*.h" "*.hpp")

message(STATUS "🍭control_module 开始构建")

add_library(control_module STATIC ${SOURCES})

target_include_directories(control_module PUBLIC 
  ${CMAKE_CURRENT_SOURCE_DIR}/  #添加当前文件目录
  ${CMAKE_SOURCE_DIR}/config   # 访问根目录生成的Config.h
)

target_link_libraries(control_module PUBLIC yj_common_module)
target_link_libraries(control_module PUBLIC rs485_module)
target_link_libraries(control_module PUBLIC agile_modbus_module)
target_link_libraries(control_module PUBLIC actuator_module)

# 链接libgoogle-glog库
find_library(GLOG_LIBRARY NAMES glog)
if(NOT GLOG_LIBRARY)
    message(FATAL_ERROR "glog library not found. Please install libgoogle-glog-dev package")
endif()

target_link_libraries(control_module
    PRIVATE
    ${GLOG_LIBRARY}
)


# 显式链接线程库
target_link_libraries(control_module PUBLIC Threads::Threads)
# 若需要进一步传递 -lrt 给依赖此库的可执行文件
target_link_options(control_module PUBLIC -lrt)




# 显式链接线程库
target_link_libraries(control_module PRIVATE Threads::Threads)
# 若需要进一步传递 -lrt 给依赖此库的可执行文件
target_link_options(control_module PRIVATE -lrt)

# # 查找Python库
# set(Python3_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/miniconda/envs/minio-python-env")
# # 强制只在虚拟环境中查找，忽略系统 Python
# set(Python3_FIND_STRATEGY "LOCATION")
# set(Python3_FIND_REGISTRY "LAST")
# set(Python3_FIND_FRAMEWORK "LAST")
# set(Python3_FIND_VIRTUALENV "ONLY")


find_package(Python3 COMPONENTS Interpreter Development REQUIRED)

message(STATUS "Python3 version: ${Python3_VERSION}")
message(STATUS "Python3 include dirs: ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3 library directories: ${Python3_LIBRARY_DIRS}")
message(STATUS "Python3 libraries: ${Python3_LIBRARIES}")
message(STATUS "Python3 execute: ${Python3_EXECUTABLE}") 



# 查找pybind11库
find_package(pybind11 REQUIRED)  
target_include_directories(control_module PUBLIC ${Python3_INCLUDE_DIRS} ${pybind11_INCLUDE_DIRS} )
target_link_libraries(control_module PUBLIC pybind11::embed ${Python3_LIBRARIES})  # 使用嵌入模式




# add_executable(python_interface ./python_interface.cpp )
# # 添加公共头文件路径
# target_include_directories(python_interface PRIVATE
#     ${CMAKE_CURRENT_BINARY_DIR}/include
#     ${CMAKE_CURRENT_BINARY_DIR}/
#     ${CMAKE_SOURCE_DIR}/config)
    
# target_link_libraries(python_interface PRIVATE control_module)



